package zw_2101_2200.zw_2133_检查是否每一行每一列都包含全部整数;

import java.util.HashSet;
import java.util.Set;

class Solution {


    public static boolean checkValid(int[][] matrix) {
        int n = matrix.length;
        Set<Integer> set1 = new HashSet<>();
        Set<Integer> set2 = new HashSet<>();
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                set1.add(matrix[i][j]);
                set2.add(matrix[j][i]);
            }
            if (set1.size() != n || set2.size() != n) {
                return false;
            }
            set1.clear();
            set2.clear();
        }
        return true;
    }
}
